package algorithm;

/**
 * 给定一个整数，编写一个函数来判断它是否是 2 的幂次方。
 */
public class T00231 {
    public static void main(String[] args) {
        System.out.println(Integer.toBinaryString(32));
        System.out.println(Integer.toBinaryString(-32));
        System.out.println(new Solution().isPowerOfTwo(0));
    }

static class Solution {
    public boolean isPowerOfTwo(int n) {
        return n > 0 && (n & -n) == n;
    }
}
}